import requests
import json


def convert_float(str):
    try:
        return float(str)
    except ValueError as e:
        return 0


for index in range(1, 282):
    json_url = f"http://48.push2.eastmoney.com/api/qt/clist/get?cb=jQuery112402508937289440778_1658838703304&pn={index}&pz=20&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&wbp2u=|0|0|0|web&fid=f3&fs=m:0+t:6,m:0+t:80,m:1+t:2,m:1+t:23,m:0+t:81+s:2048&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152&_=1658838703305"
    #print(json_url)
    res = requests.get(json_url)
    result = res.text.split("jQuery112402508937289440778_1658838703304")[1].split("(")[1].split(");")[0]

    result_json = json.loads(result)
    stock_datas = result_json['data']['diff']
    for one_stock in stock_datas:
        currentPrice = convert_float(one_stock["f2"])  # dangqianjia
        highestPrice = convert_float(one_stock["f15"]) # zuigao 
        openPrice = convert_float(one_stock["f17"])  # kaipan
        changePer = convert_float(one_stock["f3"])  # zhangfu
        volumeRate = convert_float(one_stock["f10"])  # liangbi
        turnoverRate = convert_float(one_stock["f8"])  # huanshou
        totalValue = 0
        if convert_float(one_stock["f8"]) > 0:
            totalValue = convert_float(one_stock["f6"]) / convert_float(one_stock["f8"])*100
        if currentPrice > openPrice and (highestPrice-currentPrice)/highestPrice<0.01 and changePer<9:
            if volumeRate > 1:
                if 5 < turnoverRate < 10:
                    #if 3000000000 < totalValue < 20000000000:
                        print(one_stock["f12"])

